from pathlib import Path
from typing import Union
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
from django.shortcuts import render
from django.views.generic import TemplateView

TEMPLATE_DIR = Path("app/audit/")

def template_path(path: Union[Path, str]) -> str:
    return str(TEMPLATE_DIR / path)

class BaseView(
    LoginRequiredMixin,
    PermissionRequiredMixin,
    TemplateView
):
    """
    You should set `permission_required`
    """
    template_name = template_path("table_base.html")

class AuditUserListView(BaseView):
    template_name = "app/user/management/registry.html"
    permission_required = "user.can_manage_users"


class AuditProjectRelatedListView(BaseView):
    template_name = template_path("project.html")
    permission_required = "user.can_manage_projects"

class AuditFileAccessListView(BaseView):
    permission_required = "user.can_manage_resources"
